﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aggregation_Clustering
{
    class Element
    {
        public Element()
        {//元素
            AttributesX = new ArrayList();
            ClusterID = 0;
            Before = null;
            After = null;
            ElementID = 0;
        }
        public bool addAttribute()
        {
            /*
             * add Attribute to X
             * May replace arrayList X with Array X[Fixednum]
             */
            return true;
        }
        public void MoveTo(ClusterList s,int toID)
        {//移动元素操作
            Cluster from = s.getClusterbyID(ClusterID);
            Cluster to = s.getClusterbyID(toID);
            //if it's the first element
            if (Before == null)
            {
                from.First = After;
                if (After != null) {
                    After.Before = null;
                }
            }
            else
            {
                Before.After = After;
                if (After != null)
                {
                    After.Before = Before;
                }
            }
            from.num--;
            Before = null;
            After = null;
            //remove then insert
            to.Add(this,toID);
        }
        public void setClusterID(int id) {
            ClusterID = id;
        }
        public void setElementID(int id)
        {
            ElementID = id;
        }
        public ArrayList AttributesX;//* May replace arrayList X with Array X[Fixednum]
        public int ClusterID;
        public int ElementID;
        public Element Before,After;
    }
}
